<%= settings_layout do %>
  <h2 class="text-2xl font-bold">Authentication</h2>
  <hr class="mt-3 mb-4 border-t border-base-300" />

  <%= turbo_frame_tag "sso_provider" do %>
    <% if @sso_provider.present? %>
      <div class="card bg-base-200 mb-4">
        <div class="card-body">
          <div class="flex justify-between items-start">
            <div>
              <h3 class="text-lg font-semibold"><%= @sso_provider.name %></h3>
              <div class="flex gap-2 mt-2">
                <span class="badge badge-outline">LDAP</span>
                <% if @sso_provider.enabled %>
                  <span class="badge badge-success">Enabled</span>
                <% else %>
                  <span class="badge badge-ghost">Disabled</span>
                <% end %>
              </div>
            </div>
            <div class="flex gap-2">
              <%= link_to "Edit", edit_sso_provider_path, class: "btn btn-sm btn-outline" %>
              <%= button_to "Delete", sso_provider_path, method: :delete, class: "btn btn-sm btn-error", data: { turbo_confirm: "Are you sure you want to delete this SSO provider?" } %>
            </div>
          </div>

          <% if @configuration %>
            <div class="divider"></div>
            <div class="grid grid-cols-2 gap-4">
              <div>
                <div class="text-sm font-medium text-base-content/70 mb-1">Host</div>
                <div class="font-mono"><%= @configuration.host %>:<%= @configuration.port %></div>
              </div>
              <div>
                <div class="text-sm font-medium text-base-content/70 mb-1">Base DN</div>
                <div class="font-mono"><%= @configuration.base_dn %></div>
              </div>
              <div>
                <div class="text-sm font-medium text-base-content/70 mb-1">UID Attribute</div>
                <div class="font-mono"><%= @configuration.uid_attribute %></div>
              </div>
              <div>
                <div class="text-sm font-medium text-base-content/70 mb-1">Encryption</div>
                <div class="font-mono"><%= @configuration.encryption.titleize %></div>
              </div>
            </div>
          <% end %>
        </div>
      </div>
    <% else %>
      <div class="alert mb-4">
        <iconify-icon icon="lucide:info" class="mr-2"></iconify-icon>
        <span>No SSO provider configured for this account.</span>
      </div>

      <div class="flex gap-2">
        <%= link_to "+ Add LDAP Provider", new_sso_provider_path, class: "btn btn-primary btn-sm" %>
      </div>
    <% end %>
  <% end %>
<% end %>
